import _CircularProgress from "@mui/material/CircularProgress";
import _useMediaQuery from "@mui/material/useMediaQuery";
import React, { useMemo } from "react";
import { useSelector } from "react-redux";
// import PermissionWrapper from '@/provider/permission';
import { jsx as _jsx } from "react/jsx-runtime";
function AsyncComponent(props) {
    var _useSelector = useSelector(function(state) {
        return {
            meta: state.app.meta,
            theme: state.app.theme
        };
    }), meta = _useSelector.meta, theme = _useSelector.theme;
    var isPc = _useMediaQuery("(min-width:1280px)");
    var Loading = function() {
        return /*#__PURE__*/ _jsx("div", {
            style: {
                position: "absolute",
                left: "0",
                right: "0",
                top: "0",
                bottom: "0",
                display: "flex",
                justifyContent: "center",
                alignItems: "center",
                height: meta.fullScreen ? "100vh" : "auto"
            },
            children: /*#__PURE__*/ _jsx(_CircularProgress, {
                size: isPc ? "37.6px" : "8vw",
                style: {
                    color: theme == "dark" ? "#fff" : "var(--primary)"
                },
                color: "inherit"
            })
        });
    };
    // @ts-ignore
    //   const [Component] = useSafeState(React.lazy(props.loader));
    var Component = useMemo(function() {
        return /*#__PURE__*/ React.lazy(props.loader);
    }, [
        props.loader
    ]);
    var Wrapper = useMemo(function() {
        return function(wrapperProps) {
            return /*#__PURE__*/ _jsx("div", {
                className: "animation_wrap",
                children: wrapperProps.children
            });
        };
    }, [
        props.loader
    ]);
    /** fallback 会自动在dom上增加 display:none !important 因此增加一层包裹 */ return /*#__PURE__*/ _jsx("div", {
        style: {
            height: "100%"
        },
        children: /*#__PURE__*/ _jsx(React.Suspense, {
            fallback: /*#__PURE__*/ _jsx(Loading, {}),
            children: /*#__PURE__*/ _jsx(Wrapper, {
                children: /*#__PURE__*/ _jsx(Component, {})
            })
        })
    });
}
export default AsyncComponent;

 //# sourceMappingURL=index.js.map